var mongoose = require('mongoose');
mongoose.set('debug', true);
mongoose.connect('localhost', 'test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function (callback) {
    console.log('数据库连接成功')
});
var DemoSchema = mongoose.Schema({
    left: Number,
    rent: Number
});

DemoSchema.statics.add = function () {

};
DemoSchema.statics.findAll = function (cb) {
    this.find({}, cb);
};
var Demo = mongoose.model('Demo', DemoSchema);

var d1 = new Demo({
    left: 10,
    rent: 10
});
Demo.remove({});
Demo.update({ _id: '570217e8ef4b28ca55e58aca' }, {
    $inc: {
        left: 1,
        rent: -1
    }
}, (err, d)=> {

});
Demo.findAll((err, ds)=> {
    console.log(err, ds);
});